package com.bwie.controller;

import com.bwie.pojo.First;
import com.bwie.pojo.Scend;
import com.bwie.pojo.User;
import com.bwie.service.UserService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author DarkClown
 * @date 2024-07-23 09:05
 * @project_name week0723
 * @parem
 **/
@RequestMapping("/user/user")
@RestController
@Api(tags = "用户微服务")
public class UserController {
    @Autowired
    UserService userService;

    @ApiOperation("登录")
    @PostMapping("/login")
    private R login(@RequestBody User user){
        return userService.login(user);
    }

    @ApiOperation("列表")
    @PostMapping("/list")
    private R list(@RequestBody PageInfoVo pageInfoVo){
        return userService.selectList(pageInfoVo);
    }

    @ApiOperation("添加")
    @PostMapping("/addScen")
    private R addScen(@RequestBody Scend scend){
        return userService.insertScend(scend);
    }

    @ApiOperation("删除")
    @PostMapping("/deleteScen/{id}")
    private R deleteScen(@PathVariable("id")Integer id){
        return userService.deleteById(id);
    }

    @ApiOperation("获取列表")
    @PostMapping("/firList")
    private R firList(){
        List<First> firsts = userService.selectFirList();
        return R.OK(firsts);
    }
}
